<?php

namespace IMT\AttachmentsBundle\Entity;

use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\HttpFoundation\File\File;
use Symfony\Component\Validator\Constraints as Assert;
use Vich\UploaderBundle\Mapping\Annotation as Vich;

/**
 * Attachment
 *
 * @ORM\Table(name="attachment")
 * @ORM\Entity
 * @Vich\Uploadable
 */
class Attachment
{
    /**
     * @var integer
     *
     * @ORM\Column(name="id", type="integer")
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    private $id;

    /**
     * @var string
     *
     * @ORM\Column(name="name", type="string", length=255)
     */
    private $name;
    
    /**
     * @var string
     *
     * @ORM\Column(name="fileName", type="string", length=255)
     */
    private $fileName;
    
    /**
     * @var string
     *
     * @ORM\Column(name="fileBase64", type="text")
     */
    private $fileBase64;
    
    /**
     * @Assert\File(
     *     maxSize="10M"
     * )
     * @Vich\UploadableField(mapping="attachments", fileNameProperty="fileName")
     *
     * @var File $file
     */
    protected $file;    
    
    /**
     * @var string
     *
     * @ORM\Column(name="mime", type="string", length=255)
     */
    private $mime;
    
    /**
     * @var string
     *
     * @ORM\Column(name="extension", type="string", length=255)
     */
    private $extension;
    
    /**
     * @var \Datetime
     *
     * @ORM\Column(name="dateCrea", type="datetime")
     */
    private $dateCrea;
    
    /**
     * @ORM\ManyToOne(targetEntity="IMT\EventBundle\Entity\BaseEvent", inversedBy="attachments")
     * @ORM\joinColumn(name="event_id", referencedColumnName="id")
     */
    private $event;
    
    /**
     * @ORM\ManyToOne(targetEntity="IMT\UserBundle\Entity\User", inversedBy="attachments")
     * @ORM\joinColumn(name="user_id", referencedColumnName="id")
     */
    private $user;

    public function __construct()
    {
    	$this->dateCrea = new \Datetime();
    }
    
    /**
	 * @return the $dateCrea
	 */
	public function getDateCrea() {
		return $this->dateCrea;
	}

	/**
	 * @param \Datetime $dateCrea
	 */
	public function setDateCrea(\Datetime $dateCrea) {
		$this->dateCrea = $dateCrea;
	}

	/**
     * Get id
     *
     * @return integer 
     */
    public function getId()
    {
        return $this->id;
    }
    
    public function setId($id)
    {
    	$this->id = $id;
    }

    
    /**
	 * @return the $fileBase64
	 */
	public function getFileBase64() {
		return $this->fileBase64;
	}

	/**
	 * @param string $fileBase64
	 */
	public function setFileBase64($fileBase64) {
		$this->fileBase64 = $fileBase64;
	}

	/**
     * Set name
     *
     * @param string $name
     * @return Attachment
     */
    public function setName($name)
    {
        $this->name = $name;
    
        return $this;
    }

    /**
     * Get name
     *
     * @return string 
     */
    public function getName()
    {
        return $this->name;
    }
    
	/**
	 * @return the $fileName
	 */
	public function getFileName() {
		return $this->fileName;
	}

	/**
	 * @param string $fileName
	 */
	public function setFileName($fileName) {
		$this->fileName = $fileName;
	}
	
	/**
	 * @return the $file
	 */
	public function getFile() {
		return $this->file;
	}

	/**
	 * @param \Symfony\Component\HttpFoundation\File\File $file
	 */
	public function setFile($file) {
		$this->file = $file;
	}
	
	/**
	 * @return the $mime
	 */
	public function getMime() {
		return $this->mime;
	}

	/**
	 * @return the $extension
	 */
	public function getExtension() {
		return $this->extension;
	}

	/**
	 * @param string $mime
	 */
	public function setMime($mime) {
		$this->mime = $mime;
	}

	/**
	 * @param string $extension
	 */
	public function setExtension($extension) {
		$this->extension = $extension;
	}
	
	
	/**
	 * Set event
	 *
	 * @param IMT\EventBundle\Models\EventInterface $event
	 */
	public function setEvent(\IMT\EventBundle\Models\EventInterface $event)
	{
		$this->event = $event;
	}
	
	/**
	 * Get event
	 *
	 * @return IMT\EventBundle\Models\EventInterface
	 */
	public function getEvent()
	{
		return $this->event;
	}
	
	
	/**
	 * Set user
	 *
	 * @param IMT\UserBundle\Entity\User $user
	 */
	public function setUser($user)
	{
		$this->user = $user;
	}
	
	/**
	 * Get user
	 *
	 * @return IMT\UserBundle\Entity\User $user
	 */
	public function getUser()
	{
		return $this->user;
	}
}
